//
//  SSDKPaymentData.m
//  SuperSDK
//
//  Created by wyht－ios－dev on 15/10/7.
//  Copyright © 2015年 WYHT. All rights reserved.
//

#import "SSDKPaymentData.h"
#import "SSDKDataKeys.h"

@implementation SSDKPaymentData

- (instancetype) initWithPayInfo:(SSDKPayInfo *)pInfo {
    self = [super init];
    
    if (self) {
        self.productId = pInfo.productId;
        self.productCount = [NSString stringWithFormat:@"%d",pInfo.productCount];
        self.productName = pInfo.productName;
        self.gameUid = pInfo.gameUid;
        self.serverId = [NSString stringWithFormat:@"%d",pInfo.serverId];
        self.orderAmount = [pInfo.orderAmount floatValue];
        self.roleId = pInfo.roleId;
        self.roleName = pInfo.roleName;
        self.roleGrade = [NSString stringWithFormat:@"%d",pInfo.roleGrade];
        self.roleBalance = pInfo.roleBalance;
        if(pInfo.cpOrderId!=nil && pInfo.cpOrderId.length>0)
            self.cpOrderId = pInfo.cpOrderId;
        if(pInfo.noticeUrl!=nil && pInfo.noticeUrl.length>0)
            self.noticeUrl = pInfo.noticeUrl;
        if(pInfo.currencyType!=nil && pInfo.currencyType.length>0)
            self.currencyType = pInfo.currencyType;
        if(pInfo.ticket!=nil && pInfo.ticket.length>0)
            self.ticket = pInfo.ticket;
        self.superSDKUid=pInfo.uid;
        if (pInfo.extra != nil && pInfo.extra.count > 0) {
            [self.extra addEntriesFromDictionary:pInfo.extra];
        }
        
        self.appData = pInfo.appData;
    }
    
    return self;
}

- (instancetype) setRoleId:(NSString *)roleId {
    [self.data setValue:roleId forKey:ROLE_ID];
    return self;
}

- (NSString *) roleId {
    return [self dataWithKey:ROLE_ID];
}

- (instancetype) setRoleName:(NSString *)roleName {
    return [self setDataValue:roleName forKey:ROLE_NAME];
}

- (NSString *) roleName {
    return [self dataWithKey:ROLE_NAME];
}

- (instancetype) setRoleGrade:(NSString *)roleGrade {
    return [self setDataValue:roleGrade forKey:ROLE_GRADE];
}

- (NSString *) roleGrade {
    return [self dataWithKey:ROLE_GRADE];
}

- (instancetype) setRoleBalance:(NSString *)roleBalance {
    return [self setDataValue:roleBalance forKey:ROLE_BALANCE];
}

- (NSString *) roleBalance {
    return [self dataWithKey:ROLE_BALANCE];
}

- (instancetype) setOrderId:(NSString *)orderId {
    return [self setDataValue:orderId forKey:ORDER_ID];
}

- (NSString *) orderId {
    return [self dataWithKey:ORDER_ID];
}

- (instancetype) setOrderAmount:(float)orderAmount {
    NSString *amount = [NSString stringWithFormat:@"%f", orderAmount];
    return [self setDataValue:amount forKey:ORDER_AMOUNT];
}

- (float) orderAmount {
    return [[self dataWithKey:ORDER_AMOUNT] floatValue];
}

- (instancetype) setPayStatus:(NSString *)payStatus {
    return [self setDataValue:payStatus forKey:PAY_STATUS];
}

- (NSString *) payStatus {
    return [self dataWithKey:PAY_STATUS];
}

- (instancetype) setPayTime:(long)payTime {
    NSString *time = [NSString stringWithFormat:@"%ld", payTime];
    return [self setDataValue:time forKey:PAY_TIME];
}

- (long) payTime {
    return (long)[[self dataWithKey:PAY_TIME] longLongValue];
}

- (instancetype) setPayType:(NSString *)payType {
    return [self setDataValue:payType forKey:PAY_TYPE];
}

- (NSString *) payType {
    return [self dataWithKey:PAY_TYPE];
}

- (instancetype) setSuperSDKUid:(NSString *)sUid {
    return [self setDataValue:sUid forKey:SUPERSDK_UID];
}

- (NSString *) superSDKUid {
    return [self dataWithKey:SUPERSDK_UID];
}

- (instancetype) setGameUid:(NSString *)gameUid {
    return [self setDataValue:gameUid forKey:GAME_UID];
}

- (NSString *) gameUid {
    return [self dataWithKey:GAME_UID];
}

- (instancetype) setServerId:(NSString *)serverId {
    return [self setDataValue:serverId forKey: SERVER_ID];
}

- (NSString *) serverId {
    return [self dataWithKey:SERVER_ID];
}

- (instancetype) setProductId:(NSString *)productId {
    return [self setDataValue:productId forKey:PRODUCT_ID];
}

- (NSString *) productId {
    return [self dataWithKey:PRODUCT_ID];
}

- (instancetype) setProductCount:(NSString *)productCount {
    return [self setDataValue:productCount forKey:PRODUCT_COUNT];
}

- (NSString *) productCount {
    return [self dataWithKey:PRODUCT_COUNT];
}

- (instancetype) setCpOrderId:(NSString *)cpOrderId {
    return [self setDataValue:cpOrderId forKey:CP_ORDER_ID];
}

- (NSString *) cpOrderId {
    return [self dataWithKey:CP_ORDER_ID];
}

- (instancetype) setNoticeUrl:(NSString *)noticeUrl {
    return [self setDataValue:noticeUrl forKey:NOTICE_URL];
}

- (NSString *) noticeUrl {
    return [self dataWithKey:NOTICE_URL];
}

- (instancetype) setProductName:(NSString *)productName {
    return [self setDataValue:productName forKey:PRODUCT_NAME];
}

- (NSString *) productName {
    return [self dataWithKey:PRODUCT_NAME];
}

- (instancetype) setAppData:(NSString *)appData {
    return [self setDataValue:appData forKey:APP_DATA];
}

- (NSString *) appData {
    return [self dataWithKey:APP_DATA];
}

- (instancetype) setCurrencyType:(NSString *)currencyType {
    return [self setDataValue:currencyType forKey:CURRENCY_TYPE];
}

- (NSString *) currencyType {
    return [self dataWithKey:CURRENCY_TYPE];
}

- (instancetype) setTicket : (NSString *) ticket {
    return [self setDataValue:ticket forKey:PAY_TICKET];
}

- (NSString *) ticket {
    return [self dataWithKey:PAY_TICKET];
}

@end
